<template>
  <div class="box">
    <div class="top-box">
      <div class="user-box">
        <div class="info-box">
          <span class="info-name">{{ list.nickname }}</span>
          <span class="info-signature">{{ list.intro }}</span>
        </div>
        <img
          :src="list.avatar"
          alt=""
        />
      </div>
      <div class="data-box">
        <div class="item">
          <span class="num">{{list.submitNum}}</span>
          <span>累计答题</span>
        </div>
        <div class="item">
          <span class="num">{{list.collectQuestions.length}}</span>
          <span>收藏题目</span>
        </div>
        <div class="item">
          <span class="num">{{list.errorQuestions.length}}</span>
          <span>我的错题</span>
        </div>
        <div class="item">
          <span class="num">26%</span>
          <span>正确率</span>
        </div>
      </div>
    </div>
    <div class="main-box">
      <van-cell class="post" title="我的岗位" is-link>
        <i class="iconfont iconicon_mine_gangwei" slot="icon"></i>
        <span>{{list.position}}</span>
      </van-cell>
      <div class="experience-box">
        <div class="title">面经数据</div>
        <div class="data-box">
          <div class="item">
            <div class="top">
              <span>昨日阅读</span>
              <span class="add">+{{list.shareData.read.yesterday}}</span>
            </div>
            <span class="num">{{list.shareData.read.total}}</span>
            <span class="bottom">阅读总数</span>
          </div>
          <div class="item">
            <div class="top">
              <span>昨日获赞</span>
              <span class="add">+{{list.shareData.star.yesterday}}</span>
            </div>
            <span class="num">{{list.shareData.star.total}}</span>
            <span class="bottom">获赞总数</span>
          </div>
          <div class="item">
            <div class="top">
              <span>昨日新增</span>
              <span class="add">+{{list.shareData.comment.yesterday}}</span>
            </div>
            <span class="num">{{list.shareData.comment.total}}</span>
            <span class="bottom">评论总数</span>
          </div>
        </div>
      </div>

      <van-cell class="cell" title="我的面经分享" is-link>
        <i class="iconfont iconicon_mine_mianjing" slot="icon"></i>
        <span>21</span>
      </van-cell>
      <van-cell class="cell" title="我的消息" is-link>
        <i class="iconfont iconicon_mine_xiaoxi" slot="icon"></i>
        <span>98</span>
      </van-cell>
      <van-cell class="cell" title="收藏的题库" is-link>
        <i class="iconfont iconicon_mine_tikushoucang" slot="icon"></i>
        <span>29</span>
      </van-cell>
      <van-cell class="cell" title="收藏的企业" is-link>
        <i class="iconfont iconicon_mine_qiyeshoucang" slot="icon"></i>
        <span>32</span>
      </van-cell>

      <van-cell class="cell" style="margin-bottom:75px;" title="我的错题" is-link>
        <i class="iconfont iconicon_mine_cuoti" slot="icon"></i>
        <span>123</span>
      </van-cell>
    </div>
  </div>
</template>

<script>
import '@/assets/iconfont/iconfont.css'
import { userInfoAPI } from '@/api/user'
export default {
  name: 'UserInfo',
  data () {
    return {
      list: []
    }
  },
  created () {
    this.loadData()
  },
  methods: {
    async loadData () {
      const res = await userInfoAPI()
      console.log('res:', res)
      this.list = res.data
      console.log(res.data.collectQuestions.length)
    }
  }
}
</script>

<style lang="less" scoped>
  .top-box {
  background: linear-gradient(#ce0031, #b8002c);
  height: 216px;
  width: 100%;
  .user-box {
    display: flex;
    justify-content: space-between;
    padding-top: 24px;
    padding-left: 10px;
    padding-right: 18px;
    align-items: center;
    .info-box {
      span {
        color: #fff;
        display: block;
      }
      .info-name {
        font-size: 21px;
        font-weight: 700;
      }
      .info-signature {
        display: flex;
        font-size: 12px;
        opacity: 0.7;
        margin-top: 2px;
      }
    }
    img {
      width: 45px;
      height: 45px;
      border-radius: 50%;
      border: 4px solid #c7697e;
    }
  }
  .data-box {
    display: flex;
    justify-content: space-around;
    color: #fff;
    .item {
      margin-top: 30px;
      span {
        display: block;
        text-align: center;
        font-size: 6px;
        opacity: 0.7;
      }
      .num {
        font-size: 21px;
        font-weight: 700;
        opacity: 1;
      }
    }
  }
}
.main-box {
  position: absolute;
  .post {
    display: flex;
    position: relative;
    top: -35px;
    left: 12px;
    height: 55px;
    width: 350px;
    border-radius: 7.5px;
    align-items: center;
    i {
      font-size: 20px;
    }
    .iconfont {
      font-size: 22px;
      padding-right: 20px;
    }
    span {
      margin-right: 5px;
    }
  }
  .experience-box {
    margin-top: -25px;
    margin-left: 10px; ;
    height: 125px;
    padding: 20px 15px 0;
    border-bottom: 1px solid #fafbfc;
    .title {
      display: flex;
      font-weight: 700;
    }
    .data-box {
      display: flex;
      justify-content: space-around;
      .item {
        margin-top: 10px;
        .top {
          display: flex;
          span {
            color: #b4b4bd;
          }
          .add {
            color: #53b5d1;
          }
        }
        .num {
          margin: 2px;
        }
      }
    }
  }
  .cell {
    height: 55px;
    align-items: center;
    i {
      font-size: 20px;
    }
    .iconfont {
      font-size: 22px;
      padding-right: 20px;
    }
    span {
      margin-right: 5px;
    }
  }
  .item {
    margin-top: 30px;
    span {
      display: block;
      text-align: center;
      font-size: 6px;
      opacity: 0.7;
    }
    .num {
      font-size: 21px;
      font-weight: 700;
      opacity: 1;
    }
  }
}

</style>
